import React from 'react';
import { WeaDialog, WeaFormItem, WeaSearchGroup, WeaTableEdit, WeaCheckbox, WeaInput, WeaRightMenu, WeaLocaleProvider, WeaTools } from 'ecCom';
import { WeaSwitch } from 'comsMobx';
import CofirmModal from './ConfirmModal';
import { inject, observer } from 'mobx-react';
import { Button, message, Icon, Col, Row, Modal } from 'antd';
import loadjs from 'loadjs';
const getLabel = WeaLocaleProvider.getLabel;
@inject('wfAgentStore')

@observer

export default class Main extends React.Component {

    constructor(props) {
        super(props);
    }

    componentDidMount() {
        const init=()=>{};
        loadjs.isDefined('bs_workflow_css') ? loadjs.ready('bs_workflow_css', init) : loadjs(['/spa/workflow/static4engine/engine.css'], 'bs_workflow_css', init);
    }
    
    getSearchs() {
        const { wfAgentStore } = this.props;
        const { editAgentForm, editAgentDatas } = wfAgentStore;
        const { isFormInit } = editAgentForm;
        if (!isFormInit) {
            return;
        }
        const formParams = editAgentForm.getFormParams();
        let items = [];
        items.push(
            {
                com: (
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@g0icc4@bagent`}
                        label={getLabel(17565, '被代理人')}
                        labelCol={{ span: 6 }}
                        wrapperCol={{ span: 18 }}
                    >
                        <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@ii6d78@bagentuid`} fieldConfig={editAgentDatas.bagentuid} form={editAgentForm}
                            formParams={formParams} />
                    </WeaFormItem>),
                colSpan: 1
            }, {
                com: (<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@pnk5ny@workflowPath`}
                    label={getLabel(34067, '流程路径')}
                    labelCol={{ span: 6 }}
                    wrapperCol={{ span: 18 }}
                >
                    <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@qyqs9u@workflowPath`} fieldConfig={editAgentDatas.workflowid} form={editAgentForm} formParams={formParams} />
                </WeaFormItem>),
                colSpan: 1
            }, {
                com: (
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@avcloz@date`}
                        label={`${getLabel(740, '开始日期')},${getLabel(131410, '时间')}`}
                        labelCol={{ span: 6 }}
                        wrapperCol={{ span: 18 }}
                    >
                        <div className="wf-agent-date">
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@t39b99@date`}
                                fieldConfig={editAgentDatas.beginDate}
                                form={editAgentForm}
                                formParams={formParams}
                                onChange={this.startDateChange}
                            />
                        </div>
                        <div className="wf-agent-time">
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@eg6232@time`}
                                fieldConfig={editAgentDatas.beginTime}
                                form={editAgentForm}
                                formParams={formParams}
                                onChange={this.startTimeChange}
                            />
                        </div>
                    </WeaFormItem>),
                colSpan: 1
            }, {
                com: (
                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@k369h8@date`}
                        label={`${getLabel(741, '结束日期')},${getLabel(131410, '时间')}`}
                        labelCol={{ span: 6 }}
                        wrapperCol={{ span: 18 }}
                    >
                        <div className="wf-agent-date">
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@erooqg@date`}
                                fieldConfig={editAgentDatas.endDate}
                                form={editAgentForm}
                                formParams={formParams}
                                onChange={this.endDateChange}
                            />
                        </div>
                        <div className="wf-agent-time">
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@59x7ct@time`}
                                fieldConfig={editAgentDatas.endTime}
                                form={editAgentForm}
                                formParams={formParams}
                                onChange={this.endTimeChange}
                            />
                        </div>
                    </WeaFormItem>),
                colSpan: 1
            }
        );
        return items;
    }

    startDateChange = (obj) =>  {
        const { wfAgentStore } = this.props;
        wfAgentStore.startDateChange(obj, 'editAgentDatas')
    }
    endDateChange = (obj) => {
        const { wfAgentStore } = this.props;
        wfAgentStore.endDateChange(obj, 'editAgentDatas')
    }
    startTimeChange = (obj) => {
        const { wfAgentStore } = this.props;
        wfAgentStore.startTimeChange(obj, 'editAgentForm');
    }
    endTimeChange = (obj) => {
        const { wfAgentStore } = this.props;
        wfAgentStore.endTimeChange(obj, 'editAgentForm');
    }

    tableEditChange = (datas) =>  {
        const { wfAgentStore } = this.props;
        const { agentConditionData } = wfAgentStore;
        let storeDatas = agentConditionData.slice();
        if (datas.length > storeDatas.length) {
            let item = {
                agentbatch: '0.00',
                isCreateAgenter: '0',
                isSysCreateAgenter: '0',
                isProxyDeal: '1',
                isPendThing: '0',
                agentuid: '',
                agentuidspan: '',
                conditioncn: '',
                conditionkeyid: '',
                conditionss: '',
                id: '',
                ruleRelationship: '',
                checkBoxviewAttr: 1
            };
            datas.splice(datas.length - 1, 1, item);
        }
        wfAgentStore.setAgentConditionData([...datas]);
    }

    //设置代理条件，调用E8规则选择器
    setCondition(rowindex) { 
        const { wfAgentStore } = this.props;
        const { agentConditionData, wfInfo, setConditionData, openeE9RuleDesign, isE9Rule } = wfAgentStore;
        const { workflowid, formid, isbill } = wfInfo;
        const datas = agentConditionData.slice();
        //只能从业务组件state取，不能通过可编辑table传过来，因为setState没有修改组件内datas
        const rowdata = datas[rowindex] || {};
        const { conditionkeyid, conditionss, conditioncn, ruleRelationship } = rowdata;
        let randomid = "";
        if (conditionkeyid != "") {
            randomid = conditionkeyid;
        } else {
            randomid = this.getTimeAndRandom();
        }
        if (isE9Rule) {
            let params = {
                formid: formid,
                isbill: isbill,
                linkid: randomid,
                wfid: workflowid,
            }
            openeE9RuleDesign(rowindex, params, this && this.props && this.props.ecId || '');
            const { dialogE9 } = wfAgentStore;
            dialogE9.show();
        } else {
            const url = `/formmode/interfaces/showconditionContent.jsp?rulesrc=6&formid=${formid}&isbill=${isbill}&linkid=${randomid}&isnew=1&wfid=${workflowid}&rownum=`;
            const dialog = new window.top.Dialog();
            dialog.currentWindow = window;
            dialog.Title = getLabel(520145, "代理流程处理条件设置");
            dialog.Width = 850;
            dialog.Height = 500;
            dialog.Drag = true;
            dialog.maxiumnable = true;
            dialog.URL = url;
            /******* 暂使用E8zDialog方式选择规则，规则页面设置后操作隐藏域，故采用动态添加删除隐藏域方式实现  ******/
            const condDiv = jQuery("#wf_agent_condition_" + rowindex);
            condDiv.append('<input type=hidden name=conditionss id=conditionss value="' + conditionss + '" />');
            condDiv.append('<input type=hidden name=conditioncn id=conditioncn value="' + conditioncn + '" />');
            condDiv.append('<input type=hidden name=ruleRelationship id=ruleRelationship value="' + ruleRelationship + '" />');
            const thisComp = this;
            dialog.closeHandle = function () {  //关闭时将隐藏域值放置到组件state中
                let data = {};
                const ruleRelationship = condDiv.find("#ruleRelationship").val();
                if (ruleRelationship === "") {    //清除操作
                    data["conditionss"] = "";
                    data["conditioncn"] = "";
                    data["ruleRelationship"] = "";
                    data["conditionkeyid"] = "";
                } else {
                    data["conditionss"] = condDiv.find("#conditionss").val();
                    data["conditioncn"] = condDiv.find("#conditioncn").val();
                    data["ruleRelationship"] = ruleRelationship;
                    data["conditionkeyid"] = randomid;
                }
                condDiv.find("input").remove();
                thisComp.setConditionData(rowindex, data);
            }
            if (jQuery("[name='conditionss']").size() === 1)     //有且只能一个隐藏域
                dialog.show();
        }
    }

    setConditionData(rowindex, changeData) {

        const { wfAgentStore } = this.props;
        const { agentConditionData } = wfAgentStore;

        const datas = agentConditionData.slice();

        if (datas.length > rowindex) {
            const item = { ...datas[rowindex], ...changeData };
            datas.splice(rowindex, 1, item);
            wfAgentStore.setAgentConditionData([...datas]);
        }
    }

    getTimeAndRandom() {
        let rnd = "";
        for (let i = 0; i < 2; i++) {
            rnd += Math.floor(Math.random() * 10);
        }
        return new Date().getMilliseconds() + "" + rnd;
    }

    getTitle() {
        const { wfAgentStore } = this.props;
        const { selectedRowKeys } = wfAgentStore;

        return (
            <div style={{ color: '#fff' }}>
                <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@kn2u4g`} style={{ border: 'none', padding: '0px', fontSize: '20px', lineHeight: '1', color: '#55a1f8', backgroundColor: '#fff' }} type="primary" title={getLabel(611, '添加')} size="small" onClick={this.doAddTableData}><span className="icon-coms-Add-to-hot" /></Button>
                <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@9y3b1x`} style={{ border: 'none', padding: '0px', fontSize: '20px', lineHeight: '1', color: selectedRowKeys.length <= 0 ? '#d8d8d8' : '#55a1f8', marginLeft: '10px', backgroundColor: '#fff' }} type="primary" title={getLabel(126371, '删除')} size="small" disabled={selectedRowKeys.length <= 0} onClick={this.doDeleteTableData} ><span className="icon-coms-form-delete-hot" /></Button>
            </div>
        )
    }

    doAddTableData = () => {
        const { wfAgentStore } = this.props;
        const { agentConditionData } = wfAgentStore;
        let newData = agentConditionData.slice();
        let item = {
            agentbatch: '0.00',
            isCreateAgenter: '0',
            isSysCreateAgenter: '0',
            isProxyDeal: '1',
            isPendThing: '0',
            agentuid: '',
            agentuidspan: '',
            conditioncn: '',
            conditionkeyid: '',
            conditionss: '',
            id: '',
            ruleRelationship: '',
            checkBoxviewAttr: 1
        };
        newData.push(item);
        wfAgentStore.setAgentConditionData([...newData]);
    }

    doDeleteTableData = () =>  {
        const { wfAgentStore } = this.props;
        let { selectedRowKeys, agentConditionData } = wfAgentStore;

        let newArr = agentConditionData.slice();
        let selectedKeys = selectedRowKeys.slice();
        let newDatas = [];

        newDatas = newArr.filter((item, index) => {
            if (selectedKeys.indexOf(index) < 0) {
                return true;
            }
        })

        Modal.confirm({
            title: getLabel(15172, '系统提示'),
            content: getLabel(129890, '确定要删除吗？'),
            okText: getLabel(83446, '确定'),
            cancelText: getLabel(31129, '取消'),
            onOk: () => {
                wfAgentStore.setSelectedRowKeys([]);
                wfAgentStore.setAgentConditionData([...newDatas]);
            }
        });

    }

    onRowSelect = (v) => {
        const { wfAgentStore } = this.props;
        wfAgentStore.setSelectedRowKeys([...v]);
    }

    getWeaSearchGroups() {
        const { wfAgentStore } = this.props;
        let { agentConditionData, selectedRowKeys } = wfAgentStore;
        selectedRowKeys = selectedRowKeys.slice();
        const tableColumns = [
            {
                title: getLabel(17566, '代理人'), //列名
                dataIndex: 'agentuid', //列的id 对应数据
                key: 'agentuid', //前端渲染key值
                com: [
                    {
                        label: '',
                        type: 'BROWSER',
                        editType: '1',
                        key: 'agentuid',
                        viewAttr: 3,
                        browserConditionParam: { type: '1', title: '人力资源' },
                        width: 120,
                    },
                ],
                colSpan: 1,
                width: '14%',
                className: 'wea-table-edit-agentuid',
            },
            {
                title: getLabel(383538, '代理流程创建'), //列名
                dataIndex: 'isCreateAgenter', //列的id 对应数据
                key: 'isCreateAgenter', //前端渲染key值
                com: [
                    {
                        label: '',
                        type: 'CHECKBOX',
                        editType: '1',
                        key: 'isCreateAgenter',
                        otherParams: {
                            display: 'switch',
                        }
                    },
                ],
                colSpan: 1,
                width: '14%',
                className: 'wea-table-edit-isCreateAgenter',
            },
            {
                title: getLabel(515615, '代理创建子流程'),
                dataIndex: 'isSysCreateAgenter',
                key: 'isSysCreateAgenter',
                render: (text, rowdata, rowindex) => {

                    let datas = agentConditionData.slice();
                    let newDatas = [...datas];

                    let flag = 2;

                    if (rowdata.isCreateAgenter !== '1') {
                        datas[rowindex].isSysCreateAgenter = '0';
                        newDatas[rowindex] = { ...rowdata, isSysCreateAgenter: '0' };
                        text = '0';
                        flag = 1;
                        return;
                    }

                    return <WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@gkbd7l@isSysCreateAgenter`}
                        display="switch"
                        value={text}
                        onChange={(v) => {
                            newDatas[rowindex] = { ...rowdata, isSysCreateAgenter: v };
                            wfAgentStore.setAgentConditionData([...newDatas]);
                        }}
                        viewAttr={flag}
                    />
                },
                colSpan: 1,
                width: '16%',
                className: 'wea-table-edit-isSysCreateAgenter',
            },
            {
                title: getLabel(82585, '代理流程处理'),
                dataIndex: 'isProxyDeal',
                key: 'isProxyDeal',
                com: [ //当前列中渲染的组件库组件，目前支持 select input browser checkbox
                    {
                        label: '',
                        type: 'CHECKBOX',
                        editType: '1',
                        key: 'isProxyDeal',
                        otherParams: {
                            display: 'switch'
                        }
                    },
                ],
                colSpan: 1,
                width: '14%',
                className: 'wea-table-edit-isProxyDeal',
            },
            {
                title: getLabel(33250, '代理已有待办事宜'),
                dataIndex: 'isPendThing',
                key: 'isPendThing',
                render: (text, rowdata, rowindex) => {

                    let datas = agentConditionData.slice();
                    let newDatas = [...datas];

                    let flag = 2;

                    if (rowdata.isProxyDeal !== '1') {
                        datas[rowindex].isPendThing = '0';
                        newDatas[rowindex] = { ...rowdata, isPendThing: '0' };
                        text = '0';
                        flag = 1;
                        return;
                    }

                    return <WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@aco2ba@isPendThing`}
                        display="switch"
                        value={text}
                        onChange={(v) => {
                            newDatas[rowindex] = { ...rowdata, isPendThing: v };
                            wfAgentStore.setAgentConditionData([...newDatas]);
                        }}
                        viewAttr={flag}
                    />
                },
                colSpan: 1,
                width: '17%',
                className: 'wea-table-edit-subcompany',
            },
            {
                title: getLabel(519446, '代理流程处理条件'),
                dataIndex: 'condition',
                key: 'condition',
                render: (text, rowdata, rowindex) => {
                    const conditioncn = datas[rowindex] && datas[rowindex].conditioncn || "";
                    return (<div style={{ position: 'relative' }} id={`wf_agent_condition_${rowindex}`}>
                        <i style={{ cursor: 'pointer', fontSize: 17, width: 18, height: 18, position: 'absolute', display: 'inline-block', left: 0, right: 0, top: 0, bottom: 0, margin: 'auto 0' }} onClick={this.setCondition.bind(this, rowindex)} className='icon-coms-Flow-setting' />
                        <span style={{ display: 'inline-block', marginLeft: 20, 'word-break': 'break-all' }} name="showconditioncn" dangerouslySetInnerHTML={{ __html: conditioncn }}></span>
                    </div>)
                },
                colSpan: 1,
                width: '17%',
                className: 'wea-table-edit-subcompany',
            },
            {
                title: getLabel(17892, '批次'),
                dataIndex: 'agentbatch',
                key: 'agentbatch',
                render: (text, rowdata, rowindex) => {
                    let datas = agentConditionData.slice();
                    let newDatas = [...datas];
                    return <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@9aeb32@agentbatch`}
                        value={text}
                        inputType={'FORM'}
                        detailType={3}
                        format={{}}
                        style={{}}
                        qfws={2}
                        min={0}
                        length={6}
                        onChange={(v) => {
                            let first = v.charAt(0);
                            if (first === '-') {
                                if (v.length === 1) {
                                    v = '0.00';
                                } else {
                                    v = v.substring(1)
                                }
                            }
                            if (!v) {
                                v = '0.00';
                            }
                            newDatas[rowindex] = { ...rowdata, agentbatch: v };
                            wfAgentStore.setAgentConditionData([...newDatas]);
                        }}
                    />

                },
                colSpan: 1,
                width: '8%',
                className: 'wea-table-edit-agentbatch',
            },
        ];
        let datas = agentConditionData.slice();
        const WeaSearchGroupItems = [
            {
                id: 1,
                className: "wf-agent-editgroup",
                needTigger: true,
                showGroup: true,
                col: 1,
                title: getLabel(1361, "基本信息"),
                items: this.getSearchs()
            },
            {
                id: 2,
                className: "wf-agent-conditiongroup",
                needTigger: true,
                showGroup: true,
                col: 1,
                title: getLabel(383615, "详细信息"),
                customComponent: this.getTitle(),
                items: [
                    {
                        com: <WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@wsi561@conditiongroup`}
                            isModalEdit={false}
                            columns={tableColumns}
                            datas={datas}
                            viewAttr={3}
                            onChange={this.tableEditChange}
                            showCopy={false}
                            showAdd={false}
                            showDelete={false}
                            deleteConfirm={true}
                            onRowSelect={this.onRowSelect}
                            selectedRowKeys={selectedRowKeys}
                        />
                    },
                ],
            }
        ];
        const WeaSearchGroups = WeaSearchGroupItems.map((item) => {
            return <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@9msut3@${item.id}`} customComponent={item.customComponent} key={item.id} title={item.title} className={item.className}
                items={item.items} col={item.col} showGroup={item.showGroup} needTigger={item.needTigger} />
        });
        return WeaSearchGroups;
    }

    isEqual(a, b) {
        if (a['isPendThing'] === b['isPendThing'] && a['isProxyDeal'] === b['isProxyDeal'] &&
            a['agentuid'] === b['agentuid'] && a['conditionkeyid'] === b['conditionkeyid'] &&
            a['isCreateAgenter'] === b['isCreateAgenter'] && a['conditioncn'] === b['conditioncn'] &&
            a['isSysCreateAgenter'] === b['isSysCreateAgenter'] &&
            Number(a['agentbatch']) === Number(b['agentbatch'])) {
            return true;
        }

        return false;
    }

    handleCancel = () =>  {
        const { wfAgentStore } = this.props;
        wfAgentStore.editAgent(false)
    }

    handleSave = () => {
        // 验证表单内容
        const { wfAgentStore } = this.props;
        let { ismodifyCondition, originalConditionData, editAgentForm, verifyAgentOverlap, agentid, agentConditionData, editAndSaveOtherSymbol } = wfAgentStore;
        const formParams = editAgentForm.getFormParams();

        let editParams = { ...{ agentid, symbol: editAndSaveOtherSymbol }, ...formParams };

        if (!wfAgentStore.verifyTime('editAgentForm')) {
            return;
        }

        // 验证table内容
        let datas = agentConditionData.slice();
        const rownum = datas.length;

        if (datas.length === 0) {
            Modal.warning({
                title: getLabel(131329, '信息确认'),
                content: getLabel(82681, '请至少添加一行代理设置明细!'),
                okText: getLabel(83446, '确定')
            });
            return;
        }

        let params = {};
        //数据处理和必填项检查
        try {
            datas.forEach((item, index) => {
                Object.keys(item).forEach(function (key) {
                    if (key === 'agentuid') {
                        if (item[key] === '') {
                            throw new Error("nullValue");
                        }
                        if (item[key] === formParams.bagentuid) {
                            throw new Error('samePeople')
                        }
                    } else if (key === 'agentbatch') {
                        if (item[key] === '') {
                            item[key] = 0;
                        }
                        item[key] = Number(item[key]).toFixed(2);
                    }

                    params['row_' + index + '_' + key] = item[key];
                })

                if ((item.isCreateAgenter === '' || item.isCreateAgenter === '0') && (item.isProxyDeal === '' || item.isProxyDeal === '0')) {
                    throw new Error("conditionLack");

                }
            });

        } catch (e) {
            if (e.message === 'nullValue') {
                message.warning(getLabel(130565, '必要信息不完整，红色叹号为必填项！'));
                return;
            } else if (e.message === 'conditionLack') {
                Modal.warning({
                    title: getLabel(131329, '信息确认'),
                    content: getLabel(82678, '代理流程创建 和 代理流程处理 至少启用了一项'),
                    okText: getLabel(83446, '确定')
                });
                return;
            } else if (e.message === 'samePeople') {
                Modal.warning({
                    title: getLabel(131329, '信息确认'),
                    content: getLabel(129504, '被代理人、代理人不能相同！'),
                    okText: getLabel(83446, '确定')
                });
                return;
            }

        }

        //判断是否修改table下的数据

        originalConditionData = originalConditionData.slice();
        ismodifyCondition = false;
        if (originalConditionData.length !== datas.length) {
            wfAgentStore.setIsmodifyCondition(true);
            ismodifyCondition = true;
        }

        //设置重复检查
        for (let i = 0; i < datas.length; i++) {
            //设置重复检查
            for (let j = i + 1; j < datas.length; j++) {
                if (this.isEqual(datas[i], datas[j])) {
                    Modal.warning({
                        title: getLabel(131329, '信息确认'),
                        content: getLabel(383616, '存在批次相同的重复代理设置，请检查设置！'),
                        okText: getLabel(83446, '确定')
                    });
                    return;
                }
            }
            //判断是否修改table下的数据
            if (!ismodifyCondition) {
                if (!this.isEqual(datas[i], originalConditionData[i])) {
                    wfAgentStore.setIsmodifyCondition(true);
                    ismodifyCondition = true;
                }
            }

        }

        if (editAndSaveOtherSymbol === 'edit') {
            verifyAgentOverlap({ ...editParams, rownum, ...params, ismodifyCondition });
        } else {
            wfAgentStore.dataSave({ ...editParams, rownum, ...params, ismodifyCondition });
        }

    }

    confirmOk = () => {
        const { wfAgentStore } = this.props;
        const { ismodifyCondition, addAgentForm, dataSave, agentid, agentConditionData, editAndSaveOtherSymbol } = wfAgentStore;

        let formParams = addAgentForm.getFormParams();
        let editParams = { ...{ agentid, symbol: editAndSaveOtherSymbol }, ...formParams };

        let datas = agentConditionData.slice();
        const rownum = datas.length;

        let params = {};
        //数据处理和必填项检查
        try {
            datas.forEach((item, index) => {
                Object.keys(item).forEach(function (key) {
                    if (key === 'agentuid' && item[key] === '') {
                        throw new Error("nullValue");
                    } else if (key === 'agentbatch') {
                        if (item[key] === '') {
                            item[key] = 0;
                        }
                        item[key] = Number(item[key]).toFixed(2);
                    }
                    params['row_' + index + '_' + key] = item[key];
                })

                if ((item.isCreateAgenter === '' || item.isCreateAgenter === '0') && (item.isProxyDeal === '' || item.isProxyDeal === '0')) {
                    throw new Error("conditionLack");

                }
            });

        } catch (e) {
            if (e.message === 'nullValue') {
                message.warning(getLabel(130565, '必要信息不完整，红色叹号为必填项！'));
                return;
            } else if (e.message === 'conditionLack') {
                Modal.warning({
                    title: getLabel(131329, '信息确认'),
                    content: getLabel(82678, '代理流程创建 和 代理流程处理 至少启用了一项'),
                    okText: getLabel(83446, '确定')
                });
                return;
            } else {

            }

        }

        dataSave({ ...editParams, rownum, ...params, ismodifyCondition });
        this.confirmCancel();
    }

    confirmCancel = () => {
        const { wfAgentStore } = this.props;
        wfAgentStore.repetitionValue = 0;
    }

    getFooter() {
        const { wfAgentStore } = this.props;
        const { isDisabled } = wfAgentStore;
        const footer = [
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@p0br2f@save`} disabled={isDisabled} type='primary' onClick={this.handleSave}>{getLabel(86, '保存')}</Button>,
        ];
        return footer;
    }

    getMoreBtns() {

        const { wfAgentStore } = this.props;
        let { editAndSaveOtherSymbol, isDisabled } = wfAgentStore;

        let btns = {
            datas: [],
            collectParams: {
                favname: editAndSaveOtherSymbol === 'edit' ? getLabel(383618, '编辑代理设置') : getLabel(383619, '另存为代理设置'),
                favouritetype: 2,
                objid: 0,
                importantlevel: 1,
            }
        };

        btns.datas.push(
            {
                key: '0',
                disabled: isDisabled,
                icon: <i className="icon-coms-Preservation" />,
                content: getLabel(86, '保存'),
                onClick: this.handleSave,
            }
        )

        return btns;
    }

    render() {
        const { wfAgentStore } = this.props;
        let { editAgentVisible, repetitionValue, overlapIds, editAndSaveOtherSymbol} = wfAgentStore;

        return (
            <div>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@hf8ts7`}
                    className="wf-agent-modal wf-agent-saveAsOther"
                    visible={editAgentVisible}
                    title={editAndSaveOtherSymbol === 'edit' ? getLabel(383618, '编辑代理设置') : getLabel(383619, '另存为代理设置')}
                    icon="icon-coms-workflow"
                    iconBgcolor='#0079DE'
                    maskClosable={false}
                    buttons={this.getFooter()}
                    zIndex={990}
                    onCancel={this.handleCancel}
                    hasScroll={true}
                    style={{ width: '820px', height: '520px' }}
                    moreBtn={this.getMoreBtns()}
                >
                    <CofirmModal ecId={`${this && this.props && this.props.ecId || ''}_CofirmModal@e1ql5d`}
                        visible={repetitionValue !== 0}
                        handleOk={this.confirmOk}
                        handleCancel={this.confirmCancel}
                        repetitionValue={repetitionValue}
                        overlapIds={overlapIds}
                        method={"edit"}
                    />
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@yw5z5u`}
                        {...this.getMoreBtns()}
                    >
                        {this.getWeaSearchGroups()}
                    </WeaRightMenu>
                </WeaDialog>
            </div>
        )
    }
}